<template>
    <BasicTable ref="tableRef" :params="params" :columns="columns" :load="false" :query="queryUnjoin" @select-change="onSelectChange">
        <template #form>
            <a-form-item label="用户名" name="username">
                <a-input v-model:value="params.username" placeholder="请输入用户名" />
            </a-form-item>
            <a-form-item label="手机号" name="phone">
                <a-input v-model:value="params.phone" placeholder="请输入手机号" />
            </a-form-item>
        </template>
    </BasicTable>
</template>
<script setup>
import { reactive, ref } from 'vue'
import { queryUnjoin } from '/@/api/System/Team/User'
import { BasicTable } from '@iframe/tools/components'

const tableRef = ref()
const params = reactive({})
const userIds = reactive({
    selectKeys: []
})
const columns = [
    {
        title: '用户名',
        dataIndex: 'username',
        key: 'username'
    },
    {
        title: '姓名',
        dataIndex: 'realname',
        key: 'realname'
    },
    {
        title: '工号',
        dataIndex: 'workNo',
        key: 'workNo'
    },
    {
        title: '手机号',
        dataIndex: 'phone',
        key: 'phone'
    }
]

const setTeamId = teamId => {
    params.teamId = teamId
}

const onSelectChange = selectKeys => {
    userIds.selectKeys = selectKeys
}

const getSelectUsers = () => {
    return userIds.selectKeys
}

const getTeamUserParams = () => {
    return {
        id: params.teamId,
        userIds: userIds.selectKeys
    }
}

const handleRefresh = () => {
    tableRef.value.handleRefresh()
}
defineExpose({ setTeamId, getSelectUsers, getTeamUserParams, handleRefresh })
</script>
